﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Com.Ompchina.Lib.Net;
using Model.Cms;
using Model.Config;
using BLL.Cms;
using BLL.Config;
namespace Com.Ompchina.Web
{
    public partial class list : System.Web.UI.Page
    {
        protected int TId = 0, PageIndex = 1, pID = 0;
        protected TermInfo ParentTerm = new TermInfo(), SubTerm = new TermInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            TId = RequestParam.GetInt(Request, "tid");
            PageIndex = RequestParam.GetInt(Request, "page", 1);
            if (TId == 0) 
            {
                Response.Redirect("/");
                Response.End();
            }
            ParentTerm = new TermBLL().GetTermByID(TId);
            if (ParentTerm.TermID == 0) 
            {
                Response.Redirect("/");
                Response.End();
            }

            if (ParentTerm.ParentTerm.TermID > 1)
            {
                ucMenu.ParentTermID = ParentTerm.ParentTerm.TermID;
                pID = ParentTerm.ParentTerm.TermID - 1;
                SubTerm = ParentTerm;
            }
            else
            {
                ucMenu.ParentTermID = ParentTerm.TermID;
                pID = ParentTerm.TermID - 1;
                IList<TermInfo> list = new TermBLL().ListTermByParentID(ParentTerm.TermID);
                if (list != null && list.Count > 0)
                    SubTerm = list[0];
            }
        }

        protected IList<NewsInfo> _GetNews(int pageSize, out int recordCount) 
        {
            return new NewsBLL().FrontListByTerm(SubTerm.TermID, PageIndex, pageSize, out recordCount);
        }
    }
}